package net.knightwatch.kwtools.walkthrough.items;

import android.content.Context;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.TextView;


public class Question {
	private static final String TAG = "Question";
	// Questions belong to Items and contain answers. Questions are also able to provide their layout
	private Long questionId;
	private Long parentId;
	private String question;
	private Answer answer;
	private int orderOfAppearance;
	
	public Question(){
		// TODO Creation of the question object
	}
	
	public Long getQuestionId() {
		return questionId;
	}
	public void setQuestionId(Long questionId) {
		this.questionId = questionId;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public Long getParentId() {
		return parentId;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	
	public LinearLayout getLayout(Context context){
		Log.v(TAG, "Generating the layout for the question");
		LinearLayout questionLayout = new LinearLayout(context);
		// TODO build the question layout
		// Add the textview for the question text
		questionLayout.setOrientation(LinearLayout.VERTICAL);
		TextView question_txtView = new TextView(context);
		question_txtView.setText(this.getQuestion());
		questionLayout.addView(question_txtView);
		// Add the information for the answer
		try {
			questionLayout.addView(getAnswer().getAnswerLayout(context));
		} catch (Exception e) {
			e.printStackTrace();
			Log.e(TAG,"Unable to retrieve layout for answer");
		}
		return questionLayout;
	}

	public Answer getAnswer() {
		return answer;
	}

	public void setAnswer(Answer answer) {
		this.answer = answer;
	}

	public int getOrderOfAppearance() {
		return orderOfAppearance;
	}

	public void setOrderOfAppearance(int orderOfAppearance) {
		this.orderOfAppearance = orderOfAppearance;
	}
	
	// If this has an answer check for follow up questions and provide gui update to add questions inline. 
}
